using System;
using System.Threading.Tasks;
using WorkflowCore.Interface;
using WorkflowCore.Models;
using WMSSystem.Application.Contracts.Workflow.Dto;

namespace WMSSystem.Application.Workflow
{
    /// <summary>
    /// 入库审批工作流
    /// </summary>
    public class InboundApprovalWorkflow : IWorkflow<InboundApprovalData>
    {
        public string Id => "inbound-approval-workflow";
        public int Version => 1;

        public void Build(IWorkflowBuilder<InboundApprovalData> builder)
        {
            builder
                .StartWith<CreateInboundWorkflowInstanceStep>()
                .Then<ManagerApprovalStep>()
                .Then<FinanceApprovalStep>()
                .Then<WarehouseManagerApprovalStep>()
                .Then<CompleteInboundWorkflowStep>()
                .EndWorkflow();
        }
    }

    /// <summary>
    /// 入库审批数据
    /// </summary>
    public class InboundApprovalData
    {
        public Guid BusinessId { get; set; }
        public string BusinessType { get; set; }
        public string WorkflowInstanceId { get; set; }
        public string InboundCode { get; set; }
        public decimal TotalAmount { get; set; }
        public int TotalQuantity { get; set; }
        
        // 审批人信息
        public Guid ManagerId { get; set; }
        public Guid FinanceId { get; set; }
        public Guid WarehouseManagerId { get; set; }
        
        // 审批结果
        public bool ManagerApproved { get; set; }
        public bool FinanceApproved { get; set; }
        public bool WarehouseManagerApproved { get; set; }
        
        // 审批意见
        public string ManagerComment { get; set; }
        public string FinanceComment { get; set; }
        public string WarehouseManagerComment { get; set; }
        
        // 审批时间
        public DateTime? ManagerApprovalTime { get; set; }
        public DateTime? FinanceApprovalTime { get; set; }
        public DateTime? WarehouseManagerApprovalTime { get; set; }
        
        // 当前审批步骤
        public string CurrentStep { get; set; }
        public Guid CurrentApproverId { get; set; }
    }
} 